home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 3.7 KB | 119 lines | [TEXT/ttxt] |
- --<<<
- -- Filename:
- -- adlayout.sx
- --
- -- Other Files Required:
- -- None
- --
- -- Purpose:
- -- Defines the ClassifiedAds page layout and its contents
- --
- -- Specialized Classes:
- -- PageElementButton - mixes in the actuator class with the PageElement class
- -- ThreeAdPageTemplate - defines a page layout with three ads
- --
- -- Author:
- -- Steve Gano, Dionn M. Stewart, Felicia Santelli
-
- in module Autofinder
-
- -- Define the layout we want to represent our data
- class ThreeAdPageTemplate (PageLayer)
- end
-
-
- -- A method to create a textpresenter presenter for each ad on the page.
- method makeAdtextpresenter self {class ThreeAdPageTemplate} ->
- (
- local tb
- tb := new textpresenter boundary:(new rect x2:200 y2:166) target:("" as Text)
- setDefaultAttr tb @font (new platformfont name:"Times")
- setDefaultAttr tb @size 18
- setDefaultAttr tb @leading 18
- setDefaultAttr tb @alignment @flush
- tb
- )
-
- -- A method to create a twoDshape bitmap presenter for each ad on the page.
- method makeAdPicShape self {class ThreeAdPageTemplate} ->
- (
- new TwoDShape boundary:(new rect x2:200 y2:163) stroke:blackBrush fill:blackBrush
- )
-
- method makeAdElement self {class ThreeAdPageTemplate} adPos picPos textPos ->
- (
- local picbounds:= new rect x2:200 y2:163
- local textbounds:= new rect x2:200 y2:166
-
- local adPic:= new pageElement boundary:picBounds \
- presenter:(makeAdPicShape self)\
- target:(e -> e.presenter.boundary := (getPageData e.presentedBy)[adPos].adPic)
- adPic.x := picPos.x
- adPic.y := picPos.y
- prepend self adPic
-
- local adText:= new pageElement boundary:textBounds\
- presenter:(makeAdtextpresenter self)\
- target:(e -> e.presenter.target:= ((getPageData e.presentedBy)[adPos].adText as Text))
- adText.x := textPos.x
- adText.y := textPos.y
- prepend self adText
- )
-
-
- -- instantiate all the page elements of the layout
- method init self {class ThreeAdPageTemplate} #rest args #key media:->
- (
- apply nextMethod self args
- self.stroke := whiteBrush
-
- -- CREATE ELEMENTS USED IN THE CLASSIFIED AD PAGE TEMPLATE
- -- The background picture element for the classified ads
- local bkgndPic := new pageElement boundary:media["bkgndPic"].boundary\
- presenter:media["bkgndPic"] target:media["bkgndPic"].boundary
- append self bkgndPic
-
- -- Make a text box for showing the current page number
- local pageNumberTB:= new textpresenter boundary:(new rect x2:100 y2:30)\
- target:("" as Text)
- setDefaultAttr pageNumberTB @font (new platformfont name:"Times")
- setDefaultAttr pageNumberTB @size 12
- setDefaultAttr pageNumberTB @weight @heavy
- setDefaultAttr pageNumberTB @leading 14
- setDefaultAttr pageNumberTB @alignment @flushToEnd
-
- -- Make the page element for the text box
- local pageNumElement:= new PageElement boundary:pageNumberTB.boundary\
- presenter:pageNumberTB\
- target:(e -> (e.presenter.target:= (currentpage e.presentedby) as Text))
- pageNumElement.x:= 530
- pageNumElement.y:= 455
- prepend self pageNumElement
-
- -- Make the picture and text elements for all three ads on the page
- makeAdElement self 1 (new point x:12 y:118) (new point x:12 y:290)
- makeAdElement self 2 (new point x:221 y:118) (new point x:221 y:290)
- makeAdElement self 3 (new point x:430 y:118) (new point x:430 y:290)
-
- self
- )
-
- -- SOME CONVENIENCE METHODS FOR THE THREEADPAGETEMPLATE
- -- pageData self
- -- Simply passes the request for the data on a page up to the document.
- -- currentPage self
- -- Invoked as the data method for the page element that displays the
- -- current page number. It returns a string "Page <i> of <n>".
- method getPageData self {class ThreeAdPageTemplate} ->
- (
- self.presentedBy.presentedBy.pageData
- )
-
- method currentPage self {class ThreeAdPageTemplate}->
- (
- ("Page " + (self.presentedBy.presentedBy.cursor as string) +
- " of " + ((size self.presentedBy.presentedBy) as string)) as Text
- )
- "Compiled adlayout.sx"
- -->>>
-